using System;
using System.Collections.Generic;
using Bootstrap.Models;

namespace Bootstrap.Services {

    public class FeatureDefaultDescriptor {
        public string Name { get; set; }
        public bool IsEnabled { get; set; }
        public int RenderPosition { get; set; }
        public bool IsRequired { get; set; }
        public FeatureDefaultDescriptor Enabled() {
            IsEnabled = true;
            return this;
        }

        public FeatureDefaultDescriptor Disabled() {
            IsEnabled = false;
            return this;
        }

        public FeatureDefaultDescriptor Position(int position) {
            RenderPosition = position;
            return this;
        }
        public FeatureDefaultDescriptor Required() {
            IsRequired = true;
            return this;
        }
    }

    public class VariableDefaultDescriptor {
        public string Name { get; set; }
        public string Value { get; set; }

        public VariableDefaultDescriptor WithValue(string value) {
            Value = value;
            return this;
        }
    }

    public class SettingDefaultDescriptor
    {
        public string Name { get; set; }
        public string Value { get; set; }

        public SettingDefaultDescriptor WithValue(string value)
        {
            Value = value;
            return this;
        }
    }

    public class BootstrapDefaultSettingsContext {
        public Dictionary<string, Func<FeatureDefaultDescriptor, FeatureDefaultDescriptor>> FeatureState { get; private set; }
        public Dictionary<string, Func<VariableDefaultDescriptor, VariableDefaultDescriptor>> VariableValues { get; private set; }
        public Dictionary<string, Func<SettingDefaultDescriptor, SettingDefaultDescriptor>> SettingValues { get; private set; }
        public BootstrapDefaultSettingsContext() {
            FeatureState = new Dictionary<string, Func<FeatureDefaultDescriptor, FeatureDefaultDescriptor>>();
            VariableValues = new Dictionary<string, Func<VariableDefaultDescriptor, VariableDefaultDescriptor>>();
            SettingValues = new Dictionary<string, Func<SettingDefaultDescriptor, SettingDefaultDescriptor>>();
        }

        

        public BootstrapDefaultSettingsContext Feature(string name, Func<FeatureDefaultDescriptor, FeatureDefaultDescriptor> state)
        {
            if (FeatureState.ContainsKey(name))
                FeatureState[name] = state;
            else 
                FeatureState.Add(name, state);
            return this;
        }

        public BootstrapDefaultSettingsContext Variable(string name, Func<VariableDefaultDescriptor, VariableDefaultDescriptor> value)
        {
            if (VariableValues.ContainsKey(name))
                VariableValues[name] = value;
            else
                VariableValues.Add(name, value);
            return this;
        }

        public BootstrapDefaultSettingsContext Setting(string name, Func<SettingDefaultDescriptor, SettingDefaultDescriptor> value) {
            if (SettingValues.ContainsKey(name))
                SettingValues[name] = value;
            else
                SettingValues.Add(name, value);
            return this;
        }
        
    }

   
}

